package com.ydlclass.message;

import lombok.*;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Objects;

/**
 * @author it楠老师
 * @createTime 2023-03-16
 */
@Setter
@Getter
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class MethodKey implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 调用的接口全限定名，服务端根据它找到实现
     */
    private String interfaceName;
    /**
     * 调用接口中的方法名
     */
    private String methodName;

    /**
     * 方法参数类型数组
     */
    private Class[] parameterTypes;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        MethodKey methodKey = (MethodKey) o;
        return Objects.equals(interfaceName, methodKey.interfaceName) && Objects.equals(methodName, methodKey.methodName) && Arrays.equals(parameterTypes, methodKey.parameterTypes);
    }

    @Override
    public int hashCode() {
        int result = Objects.hash(interfaceName, methodName);
        result = 31 * result + Arrays.hashCode(parameterTypes);
        return result;
    }
}
